Expand description
HTTP cookie parsing and cookie jar management.
This crates provides the Cookie
type, representing an HTTP cookie, and
the CookieJar
type, which manages a collection of cookies for session
management, recording changes as they are made, and optional automatic
cookie encryption and signing.
Usage
Add the following to the [dependencies]
section of your Cargo.toml
:
cookie = "0.11"
Then add the following line to your crate root:
extern crate cookie;
Features
This crate exposes several features, all of which are disabled by default:
-
percent-encode
Enables percent encoding and decoding of names and values in cookies.
When this feature is enabled, the
Cookie::encoded()
andCookie::parse_encoded()
methods are available. Theencoded
method returns a wrapper around aCookie
whoseDisplay
implementation percent-encodes the name and value of the cookie. Theparse_encoded
method percent-decodes the name and value of aCookie
during parsing. -
signed
Enables signed cookies via
CookieJar::signed()
.When this feature is enabled, the
CookieJar::signed()
method,SignedJar
type, andKey
type are available. The jar acts as “child jar”; operations on the jar automatically sign and verify cookies as they are added and retrieved from the parent jar. -
private
Enables private (authenticated, encrypted) cookies via
CookieJar::private()
.When this feature is enabled, the
CookieJar::private()
method,PrivateJar
type, andKey
type are available. The jar acts as “child jar”; operations on the jar automatically encrypt and decrypt/authenticate cookies as they are added and retrieved from the parent jar. -
secure
A meta-feature that simultaneously enables
signed
andprivate
.
You can enable features via Cargo.toml
:
[dependencies.cookie]
features = ["secure", "percent-encode"]
Structs
Cookie
structs.Cookie
whose Display
implementation percent-encodes the
cookie’s name and value.private
or signed
Signed
and/or Private
jars.private
signed
Enums
SameSite
cookie attribute.